package com.lbj.dao.role;

import com.lbj.bean.Role;
import com.lbj.dao.BaseDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoleDaoImpl implements RoleDao {

    @Override
    public List<Role> getRoleList(Connection connection) throws SQLException {
        PreparedStatement statement = null;
        ResultSet resultSet = null;
        String sql = "select * from smbms_role";
        ResultSet execute = BaseDao.execute(connection, statement, resultSet, sql, new Object[]{});
        List<Role> list = new ArrayList<>();
        while (execute.next()) {
            Role role = new Role();
            role.setId(execute.getInt("id"));
            role.setRoleCode(execute.getString("roleCode"));
            role.setRoleName(execute.getString("roleName"));
            list.add(role);
        }
        return list;
    }
}
